-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Earth - Denise - Tree Practice #26
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work Denise, you hit the learning goals here. I had some notes on space/time complexity. Otherwise awesome work.
# Time Complexity: log(n) | ||
# Space Complexity: log(n) | ||
|
||
def add_helper(key, value, current) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 The space/time complexity is right if the tree is balanced and O(n) if not.
# Time Complexity: O(n) | ||
# Space Complexity: O(1) | ||
def find(key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 The time complexity is right if the tree is balanced and O(n) if not. The space complexity (due to the call stack) is the same as the time complexity.
# Time Complexity: O(n) | ||
# Space Complexity: O(n) | ||
|
||
def inorder(current = @root, values = []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# Time Complexity: O(n) | ||
# Space Complexity: O(n) | ||
|
||
def preorder_helper(current, values) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# Time Complexity: O(n) | ||
# Space Complexity: O(n) | ||
|
||
def postorder_helper(current, values) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# Time Complexity: o(n) | ||
# Space Complexity: O(h), where h = height | ||
def height(current = @root) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Nice work on the space/time complexity!
No description provided.